package com.woniuxy.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.Manager;
import com.woniuxy.entity.ManagerDto;
import com.woniuxy.entity.Role;
import com.woniuxy.entity.RoleDto;
import com.woniuxy.service.ManagerService;
import com.woniuxy.service.RoleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO(用一句话描述这个类的作用)
 * @Author 18452
 * @Date 2021/4/27 10:33
 */
@Controller
@CrossOrigin
@RequestMapping("/role")
public class RoleController {
    @Resource
    private RoleService roleService;

    @RequestMapping("/select")
    @ResponseBody
    public PageInfo<Role> select(@RequestBody RoleDto roleDto){

        PageInfo<Role> rolePageInfo = roleService.select(roleDto);
        System.out.println("RoleController.select" + rolePageInfo);
        return rolePageInfo;
    }
    @RequestMapping("/selectAll")
    @ResponseBody
    public List<Role> selectAll(){
        System.out.println("----------------------selectAll");
        List<Role> roleList = roleService.selectAll();
        return roleList;
    }
    @RequestMapping("/insert")
    @ResponseBody
    public String insert(@RequestBody Role role){
        System.out.println("-------"+role);
        String result = roleService.insert(role);
        return result;
    }
    @RequestMapping("/update")
    @ResponseBody
    public String update(@RequestBody Role role){
        System.out.println("-------"+role);
        String result = roleService.update(role);
        return result;
    }
    @RequestMapping("/delete")
    @ResponseBody
    public String delete(int id){
        String result = roleService.delete(id);
        return result;
    }
}

